<?php

App::uses('AppController', 'Controller');

class SitemapController extends AppController {
	
	public $components = array( 'RequestHandler' );
	public $layout = 'xml/default';
	
	public $uses = array('Category', 'Page');
	
	public function index() {
		$this->RequestHandler->respondAs('xml');
		
		$urls = array('/', '/kalkulator', '/kontakt');
		
		$categories = $this->Category->find('all', array('fields'=>array('Category.*'), 'recursive'=>0));
		foreach ($categories as $category) {
			$urls[] = '/' . URL_SEO_PREFIX . '/' . $category['Category']['id'] . '/' . $category['Category']['key'];
		}
		
		$pages = $this->Page->find('all', array('fields'=>array('Page.*'), 'recursive'=>0));
		foreach ($pages as $page) {
			$urls[] = '/strana/' . $page['Page']['id'] . '/' . $page['Page']['key'];
		}
		
		
		$this->set('urls', $urls);
	}
	
}
